package cn.iocoder.yudao.module.product.dal.mysql.resourceshare;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.product.dal.dataobject.history.ProductBrowseHistoryDO;
import cn.iocoder.yudao.module.product.dal.dataobject.resourceshare.ResourceShareDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.product.controller.admin.resourceshare.vo.*;
import org.apache.ibatis.annotations.Select;

/**
 * 产品资源分享 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface ResourceShareMapper extends BaseMapperX<ResourceShareDO> {

    default PageResult<ResourceShareDO> selectPage(ResourceSharePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ResourceShareDO>()
                .eqIfPresent(ResourceShareDO::getResourceId, reqVO.getResourceId())
                .eqIfPresent(ResourceShareDO::getTitle, reqVO.getTitle())
                .eqIfPresent(ResourceShareDO::getCategoryId, reqVO.getCategoryId())
                .likeIfPresent(ResourceShareDO::getCategoryName, reqVO.getCategoryName())
                .eqIfPresent(ResourceShareDO::getContent, reqVO.getContent())
                .eqIfPresent(ResourceShareDO::getCoverImage, reqVO.getCoverImage())
                .eqIfPresent(ResourceShareDO::getStatus, reqVO.getStatus())
                .eqIfPresent(ResourceShareDO::getDelFlag, reqVO.getDelFlag())
                .eqIfPresent(ResourceShareDO::getDescription, reqVO.getDescription())
                .eqIfPresent(ResourceShareDO::getIsTop, reqVO.getIsTop())
                .eqIfPresent(ResourceShareDO::getKeywords, reqVO.getKeywords())
                .eqIfPresent(ResourceShareDO::getPanCode, reqVO.getPanCode())
                .eqIfPresent(ResourceShareDO::getPanUrl, reqVO.getPanUrl())
                .eqIfPresent(ResourceShareDO::getParams, reqVO.getParams())
                .eqIfPresent(ResourceShareDO::getPlatformId, reqVO.getPlatformId())
                .eqIfPresent(ResourceShareDO::getPrice, reqVO.getPrice())
                .betweenIfPresent(ResourceShareDO::getPutTime, reqVO.getPutTime())
                .eqIfPresent(ResourceShareDO::getResourceType, reqVO.getResourceType())
                .eqIfPresent(ResourceShareDO::getSearchValue, reqVO.getSearchValue())
                .eqIfPresent(ResourceShareDO::getShowCoverImage, reqVO.getShowCoverImage())
                .eqIfPresent(ResourceShareDO::getShowPanInfo, reqVO.getShowPanInfo())
                .betweenIfPresent(ResourceShareDO::getShowPutTime, reqVO.getShowPutTime())
                .eqIfPresent(ResourceShareDO::getTags, reqVO.getTags())
                .betweenIfPresent(ResourceShareDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ResourceShareDO::getCreateBy, reqVO.getCreateBy())
                .eqIfPresent(ResourceShareDO::getUpdateBy, reqVO.getUpdateBy())
                .eqIfPresent(ResourceShareDO::getRemark, reqVO.getRemark())
                .orderByDesc(ResourceShareDO::getId));
    }

    @Select("SELECT * FROM product_resource_share WHERE resource_id=#{resourceId} limit 1")
    ResourceShareDO selectByResourceId(Integer resourceId);

}